<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload = function() {
            var xhr = null;
            if (window.XMLHttpRequest) {
                xhr = new XMLHttpRequest()
            } else {
                xhr = new ActiveXObject("Microsoft.XMLHTTP");
            }
            xhr.open('get', './ajax.php?user=zhangsan');

            xhr.send(null);

            xhr.oureadystatechage = function() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200) {
                        document.getElementsByTagName('span')[0].innerHTML = xhr.responseText;
                    }
                }
            }
        }
    </script>
</head>

<body>

</body>

</html>